package 剑指offer;

/**
 * Created by sult on 2018/9/29.
 */
public class 斐波那契数列 {

    public static int findN(int n){
        if(n==1){
            return 0;
        }
        if(n==2){
            return 1;
        }
        int f1=0;
        int f2=1;
        int value=0;
        for(int i=3;i<=n;i++){
            value=f1+f2;
            f1=f2;
            f2=value;

        }
        return value;
    }

    public static void main(String [] args){
        System.out.println(findN(4));
        System.out.println(findN(5));
        System.out.println(findN(6));
    }
}
